<?php

namespace coser;

class Config
{
    protected static $config = [];

    //载入配置文件
    public static function load($file,$name = '')
    {
        //检查文件是否存在
        if(is_file($file)){
            $name = strtolower($name);
            return self::set(include $file,$name);
        }

        return self::$config;
    }

    //设置配置
    public static function set($value,$name)
    {
        if(is_array($value)){
            self::$config[$name] = $value;
        }
        return self::$config[$name];
    }

    //获取配置
    public static function get($name = '')
    {
        if(!empty($name)){
            return self::$config[$name];
        }
        return self::$config;
    }

}